﻿<%@ Page Language="C#" EnableEventValidation="false" AutoEventWireup="true" CodeBehind="XianQingHuiBao.aspx.cs" Inherits="Catering.Catering_Page.richang.XianQingHuiBao" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>培训应急</title>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Scripts/zhezhao.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="../../Scripts/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../../Scripts/uploader/jquery.uploadify.v2.1.0.min.js"></script>
    <script type="text/javascript" src="../../Scripts/uploader/swfobject.js"></script>
    <link type="text/css" href="../../Scripts/uploader/uploadify.css" rel="stylesheet" />
    <link href="../../Style/center.css" rel="stylesheet" type="text/css" />
    <link href="../../Style/sysData.css" rel="stylesheet" type="text/css" />
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {
            $("#txt_guanbishijian").focus(function () { WdatePicker({ dateFmt: 'yyyy-MM-dd' }) });
            $("#txt_fashengshijian").focus(function () { WdatePicker({ dateFmt: 'yyyy-MM-dd' }) });
            $("input[name='rbm']").change(function () {
                var _thisval = $(this).val();
                if (_thisval == "是") {
                    $("#btn_add").removeAttr("disabled");
                } else if (_thisval == "否") {
                    $("#btn_add").attr("disabled", "disabled");
                }
            });

            $("#Imgfile").uploadify({
                'uploader': '../../Scripts/uploader/uploadify.swf',
                'script': 'Upload.aspx',
                'cancelImg': '../../Scripts/uploader/cancel.png',
                'folder': '../../UpFile',
                'queueID': 'fileQueue',
                'buttonImg': '../../Scripts/uploader/liulan.png',
                'auto': false,
                'multi': true,
                'onComplete': function fun(event, queueID, fileObj, response, data) {
                    if (response == "true") {
                        alert("文件上传成功！");
                        $("#hdn_filepath").val(fileObj.name);
                    }
                    else if (response == "false") {
                        alert("文件上传出错！");
                    }
                },
                'onSelect': function (e, queueId, fileObj) {
                    $('#Imgfile').uploadifyUpload();
                },
                'onCancel': function (file) {

                }
            });
        });

        //添加数据
        function btn_Add() {
            var txt_mingcheng = $("#txt_mingcheng").val();
            var ddl_leibie = $("#ddl_leibie").val();
            var txt_fuzeren = $("#txt_fuzeren").val();
            var txt_fashengshijian = $("#txt_fashengshijian").val();
            var txt_guanbishijian = $("#txt_guanbishijian").val();
            var txt_zhenggaicuoshi = $("#txt_zhenggaicuoshi").val();

            var hdn_useDate = $("#hdn_useDate").val();
            var hdn_currentClassID = $("#hdn_currentClassID").val();
            var hdn_currentGroppID = $("#hdn_currentGroppID").val();
            var hdn_filepath = $("#hdn_filepath").val();

            var _ribaobianhao = hdn_useDate + "," + hdn_currentClassID + "," + hdn_currentGroppID + ",";


            $.ajax({
                type: "Post",
                url: "XianQingHuiBao.aspx/Add",
                data: "{'txt_mingcheng':'" + txt_mingcheng + "','ddl_leibie':'" + ddl_leibie + "','txt_fuzeren':'" + txt_fuzeren + "' , 'txt_fashengshijian':'" + txt_fashengshijian + "' , 'txt_guanbishijian':'" + txt_guanbishijian + "','txt_zhenggaicuoshi':'" + txt_zhenggaicuoshi + "','ribaobianhao':'" + _ribaobianhao + "','hdn_filepath':'" + hdn_filepath + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "ok") {
                        alert("保存成功！");
                        window.location.href = 'XianQingHuiBao.aspx';
                    }
                }
            });
        }
        //获取数据
        function btn_Get(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "XianQingHuiBao.aspx/Get",
                data: "{'_id':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_fashengshijian").val(data.d[0] == null ? "" : data.d[0]);
                    $("#txt_fuzeren").val(data.d[1] == null ? "" : data.d[1]);
                    $("#txt_guanbishijian").val(data.d[2] == null ? "" : data.d[2]);
                    $("#ddl_leibie").val(data.d[3] == null ? "" : data.d[3]);
                    $("#txt_mingcheng").val(data.d[4] == null ? "" : data.d[4]);
                    $("#txt_zhenggaicuoshi").val(data.d[5] == null ? "" : data.d[5]);
                    $("#hdn_filepath").val(data.d[6] == null ? "" : data.d[6]);
                    $("#btn_Edit").show();
                    $("#btn_Add").hide();
                    divshow("xqsj_div", "bg");
                }
            });
        }
        //编辑数据
        function btn_Edit() {
            var txt_mingcheng = $("#txt_mingcheng").val();
            var ddl_leibie = $("#ddl_leibie").val();
            var txt_fuzeren = $("#txt_fuzeren").val();
            var txt_fashengshijian = $("#txt_fashengshijian").val();
            var txt_guanbishijian = $("#txt_guanbishijian").val();
            var txt_zhenggaicuoshi = $("#txt_zhenggaicuoshi").val();
            var cid = $("#HidID").val();
            var hdn_filepath = $("#hdn_filepath").val();

            $.ajax({
                type: "Post",
                url: "XianQingHuiBao.aspx/Edit",
                data: "{'_id':'" + cid + "','txt_mingcheng':'" + txt_mingcheng + "','ddl_leibie':'" + ddl_leibie + "','txt_fuzeren':'" + txt_fuzeren + "' , 'txt_fashengshijian':'" + txt_fashengshijian + "' , 'txt_guanbishijian':'" + txt_guanbishijian + "' , 'txt_zhenggaicuoshi':'" + txt_zhenggaicuoshi + "','hdn_filepath':'" + hdn_filepath + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'XianQingHuiBao.aspx';
                    }
                }
            });
        }

        function click_Download(yjqk_id) {
            if (yjqk_id != null && yjqk_id != "")
            {
                $("#frame_download").attr("src", "../../UpFile/" + yjqk_id);
            }
        }
    </script>
</head>
<body style="background-color:#E5F1FD">
    <input type="hidden" id="HidID" />
    <form id="Form1" runat="server">
        <%
            string useDate = null;
            string currentClassID = null;
            string currentGroppID = null;
            if (Session["useDate"] != null)
                useDate = Session["useDate"].ToString();
            if (Session["ClassID"] != null)
                currentClassID = Session["ClassID"].ToString();
            if (Session["GroppID"] != null)
                currentGroppID = Session["GroppID"].ToString();
        %>
        <input type="hidden" id="hdn_useDate" value='<%=useDate%>' />
        <input type="hidden" id="hdn_currentClassID" value='<%=currentClassID%>' />
        <input type="hidden" id="hdn_currentGroppID" value='<%=currentGroppID%>' />
        <table width="500">
            <tr>
                <td>险情汇报：
                    <input type="radio" name="rbm" value="是" checked="checked" />是
	                <input type="radio" name="rbm" value="否" />否
                </td>
                <td>
                    <input id="btn_add" type="button" onclick="$('#btn_Edit').hide(); divshow('xqsj_div', 'bg')" class="input_btn_a" value="新增" />
                </td>
            </tr>
            <tr id="tr_xqhb">
                <td align="center" colspan="2">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" class="swxx_table">
                        <thead>
                            <tr>
                                <td>名称
                                </td>
                                <td>类别
                                </td>
                                <td>负责人
                                </td>
                                <td>发生时间
                                </td>
                                <td>关闭时间
                                </td>
                                <td>操作
                                </td>
                            </tr>
                        </thead>
                        <tbody>
                            <asp:Repeater ID="rpt_xiaoqinghuibao" runat="server" OnItemCommand="rpt_xiaoqinghuibao_ItemCommand">
                                <ItemTemplate>
                                    <tr>
                                        <td>
                                            <%#Eval("mingcheng")%>
                                        </td>
                                        <td>
                                            <%#Eval("leibie")%>
                                        </td>
                                        <td>
                                            <%#Eval("fuzeren")%>
                                        </td>
                                        <td><%#Eval("fashengshijian","{0:yyyy-MM-dd}")%></td>
                                        <td><%#Eval("guanbishijian","{0:yyyy-MM-dd}")%></td>
                                        <td align="center">
                                            <img alt="" src="../../../Images/download.gif" style="cursor: pointer;" onclick="click_Download('<%#Eval("xianqingbaogao")%>')"/>
                                            <img alt="" src="../../Images/file.gif" onclick="btn_Get('<%#Eval("id")%>')" style="cursor: pointer;" />
                                            <asp:ImageButton ID="img_btn" runat="server" ImageUrl="../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                                CommandArgument='<%#Eval("id")%>' CommandName="del" />
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </tbody>
                    </table>
                </td>
            </tr>
        </table>
    </form>
    <!--弹出层背景-->
    <div id="bg" class="bg">
    </div>
    <!--弹出层应急情况-->
    <div id="xqsj_div" class="center_div" style="width: 400px; height: 350px; padding: 0px; margin-top: -100px;margin-left: 1px;">
        <div class="div_0207" style="width: 398px; height: 100%; margin: 0px;">
            <h1>
                <img alt="险情事件" src="../../Images/cp_h1_03.gif" />添加险情事件</h1>
            <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="65" height="40" align="right">名称：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_mingcheng" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td align="right">类别：
                    </td>
                    <td>
                        <select id="ddl_leibie">
                            <option value="人员伤害">人员伤害</option>
                            <option value="环境污染">环境污染</option>
                            <option value="社会影响">社会影响</option>
                            <option value="财产损失">财产损失</option>
                            <option value="潜在重大风险">潜在重大风险</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td width="65" height="40" align="right">负责人：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_fuzeren" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td width="65" height="40" align="right">险情整改措施：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_zhenggaicuoshi" style="height:40px;width:110px" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td align="right">险情报告：
                    </td>
                    <td>
                        <input type="hidden" id="hdn_filepath"/>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <input type="file" id="Imgfile" style="height:22px; vertical-align:middle;" />
                    </td>
                </tr>
                <tr>
                    <td width="65" height="40" align="right">发生时间：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_fashengshijian" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td width="65" height="40" align="right">关闭时间：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_guanbishijian" class="input_bg" />
                    </td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td height="30" align="right">
                        <input type="button" id="btn_Add" onclick="btn_Add()" class="input_btn_a" value="提交" />
                        <input type="button" id="btn_Edit" onclick="btn_Edit()" class="input_btn_a" value="提交" />
                    </td>
                    <td>
                        <input type="button" id="but_Close" onclick='divhidel("xqsj_div", "bg")' class="input_btn_a"
                            value="关闭" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <!--弹出层应急情况   结束-->
    <iframe style="display:none;" id="frame_download" name="frame_download"></iframe>
</body>
</html>
